//
//  MCMarketingDetailCell.swift
//  StoreManage
//
//  Created by MC on 2018/6/27.
//  Copyright © 2018年 MC. All rights reserved.
//

import UIKit


class MCMarketingDetailCell: UITableViewCell {
    
    
    var model : MCResueGoodsModel = MCResueGoodsModel() {
        didSet {
            iconImageView.sd_setImage(with: URL.init(string: model.navigateImg1), placeholderImage: #imageLiteral(resourceName: "Reuse_placeholder_1_1"))
            nameLabel.text = model.goodsName
            moneyLabel.text = MCString_judgemantDecimalsIsZero(figure: model.salePrice.intValue)
            suggestMoneyLabel.text = "市场价:" + MCString_judgemantDecimalsIsZero(figure: model.suggestedPrice.intValue)
            countLabel.text = "已售:" + model.hasSellCount.stringValue

        }
    }
    
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        self.backgroundColor = UIColor.MCGray_light
        
        self.addSubview(bgView)
        bgView.snp.remakeConstraints { (make) ->Void in
            make.edges.equalTo(self).inset(UIEdgeInsetsMake(10, 0, 0, 0))
        }
        
        
        bgView.addSubview(iconImageView)
        iconImageView.snp.remakeConstraints { (make) ->Void in
            make.centerY.equalTo(bgView)
            make.left.equalTo(15)
            make.size.equalTo(CGSize.init(width: 80, height: 80))
        }
        
        
        bgView.addSubview(suggestMoneyLabel)
        suggestMoneyLabel.snp.remakeConstraints { (make) ->Void in
            make.left.equalTo(iconImageView.snp.right).offset(5)
            make.bottom.equalTo(iconImageView).offset(-2)
        }
        
        bgView.addSubview(countLabel)
        countLabel.snp.remakeConstraints { (make) ->Void in
            make.right.equalTo(bgView).offset(-10)
            make.bottom.equalTo(suggestMoneyLabel)
        }

        
        bgView.addSubview(moneyLabel)
        moneyLabel.snp.remakeConstraints { (make) ->Void in
            make.left.equalTo(iconImageView.snp.right).offset(5)
            make.bottom.equalTo(suggestMoneyLabel.snp.top).offset(-5)
        }
        
        bgView.addSubview(nameLabel)
        nameLabel.snp.remakeConstraints { (make) ->Void in
            make.left.equalTo(iconImageView.snp.right).offset(5)
            make.top.equalTo(iconImageView)
            make.right.equalTo(bgView).offset(-5)
            make.bottom.lessThanOrEqualTo(moneyLabel.snp.top).offset(-5)
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    lazy var bgView: UIView = {
        let view = UIView()
        view.backgroundColor = UIColor.white
        view.layer.cornerRadius = 4
        view.layer.masksToBounds = true
        return view
    }()
    
    lazy var iconImageView: UIImageView = {
        let imageView = UIImageView()
        imageView.image = #imageLiteral(resourceName: "Reuse_placeholder_1_1")
        return imageView
    }()
    
    
    lazy var nameLabel: UILabel = {
        let label = UILabel()
        label.textColor = UIColor.black
        label.numberOfLines = 0
        label.font = MCFont(14)
        return label
    }()
    
    lazy var moneyLabel: UILabel = {
        let label = UILabel()
        label.textColor = UIColor.MCMain
        label.font = MCFont(13)
        return label
    }()
    
    lazy var suggestMoneyLabel: UILabel = {
        let label = UILabel()
        label.textColor = UIColor.MCGray_middle
        label.font = MCFont(13)
        return label
    }()

    
    lazy var countLabel: UILabel = {
        let label = UILabel()
        label.textColor = UIColor.MCGray_middle
        label.font = MCFont(13)
        return label
    }()
    
}
